package com.woniuxy.main.handler;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.woniuxy.main.pojo.Comment;
import com.woniuxy.main.service.CommentService;

import lombok.Data;

@Controller
@RequestMapping("/comment")
@Scope("prototype")
@Data
public class CommentHandler {
	
	@Resource
	private CommentService commentService;
	
	//生成评价信息
	@RequestMapping("/insertComment")
	@ResponseBody
	public String insertComment(Comment comment){
		String result = "提交失败！";
		System.out.println(comment);
		int row = commentService.insertComment(comment);
		if(row > 0){
			result = "提交成功！";
		}
		return result;
	}
	
	//获取评价信息
	@RequestMapping("/getComment")
	@ResponseBody
	public Comment getComment(Comment comment){
		System.out.println(comment+"-------------------");
		return commentService.getComment(comment);
	}
	
}
